<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    (function () {
        function server() {

            this.obj = {}

            this.on = function (type, handler) {
                this.obj[type] = this.obj[type] || []
                this.obj[type].push(handler)
            }
            this.emit = function (type, msg) {
                if (this.obj[type]) {
                    this.obj[type].forEach(item => {
                        item(msg)
                    });
                }
            }
        }
        window.server = server;
    })()
    
    let a = new server();
    a.on('李佳奇',function(msg){
        console.log('她收到了来自李佳奇的消息：'+msg);
    })
    a.on('李佳奇',function(msg){
        console.log('他收到了来自李佳奇的消息：'+msg);
    })
    a.on('李佳奇',function(msg){
        console.log('它收到了来自李佳奇的消息：'+msg);
    })
    a.on('李佳奇',function(msg){
        console.log('她们收到了来自李佳奇的消息：'+msg);
    })
    a.on('李佳奇',function(msg){
        console.log('他们收到了来自李佳奇的消息：'+msg);
    })
    a.emit('李佳奇','今天卢忠旭要中福彩一等大奖了')
</script>